﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Test page</title>
</head>

<script src="../Javascript/prototype.js" type="text/javascript"></script>

<script language="javascript" type="text/javascript">
document.Services = "GigitiService.asmx";
function removeXML(text){
	text=text.replace('<?xml version="1.0" encoding="utf-8"?>','');
	if(text.indexOf('>')!=-1)	text=text.substring(text.indexOf('>')+1)
	text=text.replace(/&gt;/g,'>');
	text=text.replace(/&lt;/g,'<');
	text=text.replace(/&amp;/g,'&');
	text=text.replace('</string>','');
	return text;
}

Search = function(){
    YahooWebsearch(1);
    EbayWebsearch(1);
    _TopTenYahooSearch();
};     
     
YahooWebsearch = function(PageIndex){
	    oParam = 'KeyWard='+$('txtKeyward').value+'&PageIndex='+PageIndex;
	    
        new Ajax.Request(document.Services+'/YahooWebsearch',{
                method: 'post',
                parameters: oParam, 
                onComplete: _YahooWebsearch
            }
        );
};
_YahooWebsearch = function(Result){
    $('YahooWebsearchResult').innerHTML = removeXML(Result.responseText);
};

EbayWebsearch = function(PageIndex){
	    oParam = 'KeyWard='+$('txtKeyward').value+'&PageIndex='+PageIndex;
	    
        new Ajax.Request(document.Services+'/EbayWebsearch',{
                method: 'post',
                parameters: oParam, 
                onComplete: _EbayWebsearch
            }
        );
};
_EbayWebsearch = function(Result){
    $('EbayWebsearchResult').innerHTML = removeXML(Result.responseText);
};

TopTenYahooSearch = function(){
	    oParam = 'KeyWard='+$('txtKeyward').value;
	    
        new Ajax.Request(document.Services+'/YahooWebsearchTopTen',{
                method: 'post',
                parameters: oParam, 
                onComplete: _TopTenYahooSearch
            }
        );
};
_TopTenYahooSearch  = function(Result){
    $('TopTenResult').innerHTML = removeXML(Result.responseText);
};

</script>

<body>
    <input id="txtKeyward" type="text" />
    <input id="btnSearch" type="button" value="Search" onclick="Search();" />
    <div id="TopTenResult">
    </div>
    <div id="YahooWebsearchResult">
    </div>
    <div id="EbayWebsearchResult">
    </div>
    
</body>
</html>
